|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1989, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Author: Chris D. Peterson, Dave Sternlicht, MIT X Consortium
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <X11/IntrinsicP.h> /* To get into the composite and core widget
|
|
Packit Service |
2b1f13 |
structures. */
|
|
Packit Service |
2b1f13 |
#include <X11/ObjectP.h> /* For XtIs<Classname> macros. */
|
|
Packit Service |
2b1f13 |
#include <X11/StringDefs.h> /* for XtRString. */
|
|
Packit Service |
2b1f13 |
#include <X11/ShellP.h> /* for Application Shell Widget class. */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#include <X11/Xatom.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xos.h> /* for strcpy declaration */
|
|
Packit Service |
2b1f13 |
#include <X11/Xfuncs.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/EditresP.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmd.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/CharSet.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/SysUtil.h>
|
|
Packit Service |
2b1f13 |
#include <stdio.h>
|
|
Packit Service |
2b1f13 |
#include <stdlib.h>
|
|
Packit Service |
2b1f13 |
#include <string.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define _XEditResPutBool _XEditResPut8
|
|
Packit Service |
2b1f13 |
#define _XEditResPutResourceType _XEditResPut8
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Types
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
typedef enum {
|
|
Packit Service |
2b1f13 |
BlockNone,
|
|
Packit Service |
2b1f13 |
BlockSetValues,
|
|
Packit Service |
2b1f13 |
BlockAll
|
|
Packit Service |
2b1f13 |
} EditresBlock;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _SetValuesEvent {
|
|
Packit Service |
2b1f13 |
EditresCommand type; /* first field must be type */
|
|
Packit Service |
2b1f13 |
WidgetInfo *widgets;
|
|
Packit Service |
2b1f13 |
unsigned short num_entries; /* number of set values requests */
|
|
Packit Service |
2b1f13 |
char *name;
|
|
Packit Service |
2b1f13 |
char *res_type;
|
|
Packit Service |
2b1f13 |
XtPointer value;
|
|
Packit Service |
2b1f13 |
unsigned short value_len;
|
|
Packit Service |
2b1f13 |
} SetValuesEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _SVErrorInfo {
|
|
Packit Service |
2b1f13 |
SetValuesEvent *event;
|
|
Packit Service |
2b1f13 |
ProtocolStream *stream;
|
|
Packit Service |
2b1f13 |
unsigned short *count;
|
|
Packit Service |
2b1f13 |
WidgetInfo *entry;
|
|
Packit Service |
2b1f13 |
} SVErrorInfo;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _GetValuesEvent {
|
|
Packit Service |
2b1f13 |
EditresCommand type; /* first field must be type */
|
|
Packit Service |
2b1f13 |
WidgetInfo *widgets;
|
|
Packit Service |
2b1f13 |
unsigned short num_entries; /* number of get values requests */
|
|
Packit Service |
2b1f13 |
char *name;
|
|
Packit Service |
2b1f13 |
} GetValuesEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _FindChildEvent {
|
|
Packit Service |
2b1f13 |
EditresCommand type; /* first field must be type */
|
|
Packit Service |
2b1f13 |
WidgetInfo *widgets;
|
|
Packit Service |
2b1f13 |
short x, y;
|
|
Packit Service |
2b1f13 |
} FindChildEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _GenericGetEvent {
|
|
Packit Service |
2b1f13 |
EditresCommand type; /* first field must be type */
|
|
Packit Service |
2b1f13 |
WidgetInfo *widgets;
|
|
Packit Service |
2b1f13 |
unsigned short num_entries; /* number of set values requests */
|
|
Packit Service |
2b1f13 |
} GenericGetEvent, GetResEvent, GetGeomEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Common to all events
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
typedef struct _AnyEvent {
|
|
Packit Service |
2b1f13 |
EditresCommand type; /* first field must be type */
|
|
Packit Service |
2b1f13 |
WidgetInfo *widgets;
|
|
Packit Service |
2b1f13 |
} AnyEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* The event union
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
typedef union _EditresEvent {
|
|
Packit Service |
2b1f13 |
AnyEvent any_event;
|
|
Packit Service |
2b1f13 |
SetValuesEvent set_values_event;
|
|
Packit Service |
2b1f13 |
GetResEvent get_resources_event;
|
|
Packit Service |
2b1f13 |
GetGeomEvent get_geometry_event;
|
|
Packit Service |
2b1f13 |
FindChildEvent find_child_event;
|
|
Packit Service |
2b1f13 |
} EditresEvent;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
typedef struct _Globals {
|
|
Packit Service |
2b1f13 |
EditresBlock block;
|
|
Packit Service |
2b1f13 |
SVErrorInfo error_info;
|
|
Packit Service |
2b1f13 |
ProtocolStream stream;
|
|
Packit Service |
2b1f13 |
ProtocolStream *command_stream; /* command stream */
|
|
Packit Service |
2b1f13 |
#if defined(LONG64) || defined(WORD64)
|
|
Packit Service |
2b1f13 |
unsigned long base_address;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
} Globals;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define CURRENT_PROTOCOL_VERSION 5L
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define streq(a,b) (strcmp((a), (b)) == 0)
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Prototypes
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Widget _FindChild(Widget, int, int);
|
|
Packit Service |
2b1f13 |
static void _XEditresGetStringValues(Widget, Arg*, int);
|
|
Packit Service |
2b1f13 |
static XtPointer BuildReturnPacket(ResIdent, EditResError, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static void CommandDone(Widget, Atom*, Atom*);
|
|
Packit Service |
2b1f13 |
static Boolean ConvertReturnCommand(Widget, Atom*, Atom*, Atom*, XtPointer*,
|
|
Packit Service |
2b1f13 |
unsigned long*, int*);
|
|
Packit Service |
2b1f13 |
static Boolean CvtStringToBlock(Display*, XrmValue*, Cardinal*,
|
|
Packit Service |
2b1f13 |
XrmValue*, XrmValue*, XtPointer*);
|
|
Packit Service |
2b1f13 |
static EditresEvent *BuildEvent(Widget, Atom, XtPointer, ResIdent,
|
|
Packit Service |
2b1f13 |
unsigned long);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DoFindChild(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DoGetGeometry(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DoGetResources(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DoSetValues(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static void DumpChildren(Widget, ProtocolStream*, unsigned short*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DumpValues(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *DumpWidgets(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static void ExecuteCommand(Widget, Atom, ResIdent, EditresEvent*);
|
|
Packit Service |
2b1f13 |
static void ExecuteGetGeometry(Widget, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static void ExecuteGetResources(Widget w, ProtocolStream *stream);
|
|
Packit Service |
2b1f13 |
static void ExecuteSetValues(Widget, SetValuesEvent*, WidgetInfo*,
|
|
Packit Service |
2b1f13 |
ProtocolStream*, unsigned short*);
|
|
Packit Service |
2b1f13 |
static void FreeEvent(EditresEvent*);
|
|
Packit Service |
2b1f13 |
static void GetCommand(Widget w, XtPointer, Atom*, Atom*, XtPointer,
|
|
Packit Service |
2b1f13 |
unsigned long*, int*);
|
|
Packit Service |
2b1f13 |
static void HandleToolkitErrors(String, String, String, String,
|
|
Packit Service |
2b1f13 |
String*, Cardinal*);
|
|
Packit Service |
2b1f13 |
static void InsertWidget(ProtocolStream*, Widget);
|
|
Packit Service |
2b1f13 |
static Bool IsChild(Widget, Widget, Widget);
|
|
Packit Service |
2b1f13 |
static Bool isApplicationShell(Widget);
|
|
Packit Service |
2b1f13 |
static void LoadResources(Widget);
|
|
Packit Service |
2b1f13 |
static Bool PositionInChild(Widget, int, int);
|
|
Packit Service |
2b1f13 |
static int qcmp_widget_list(register _Xconst void*, register _Xconst void*);
|
|
Packit Service |
2b1f13 |
static void SendCommand(Widget, Atom, ResIdent, EditResError,
|
|
Packit Service |
2b1f13 |
ProtocolStream*);
|
|
Packit Service |
2b1f13 |
static void SendFailure(Widget, Atom, ResIdent, _Xconst char*);
|
|
Packit Service |
2b1f13 |
static _Xconst char *VerifyWidget(Widget, WidgetInfo*);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* External
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void _XEditResCheckMessages(Widget, XtPointer, XEvent*, Boolean*);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Initialization
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Atom res_editor_command, res_editor_protocol, client_value;
|
|
Packit Service |
2b1f13 |
static Globals globals;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Resource Editor Communication Code
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResCheckMessages
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* data - unused
|
|
Packit Service |
2b1f13 |
* event - The X Event that triggered this handler
|
|
Packit Service |
2b1f13 |
* cont - unused
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* This callback routine is set on all shell widgets, and checks to
|
|
Packit Service |
2b1f13 |
* see if a client message event has come from the resource editor.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResCheckMessages(Widget w, XtPointer data, XEvent *event, Boolean *cont)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Time time;
|
|
Packit Service |
2b1f13 |
ResIdent ident;
|
|
Packit Service |
2b1f13 |
static Boolean first_time = False;
|
|
Packit Service |
2b1f13 |
static Atom res_editor, res_comm;
|
|
Packit Service |
2b1f13 |
Display *dpy;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (event->type == ClientMessage)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XClientMessageEvent * c_event = (XClientMessageEvent *)event;
|
|
Packit Service |
2b1f13 |
dpy = XtDisplay(w);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!first_time)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Atom atoms[4];
|
|
Packit Service |
2b1f13 |
static _Xconst char *names[] = {
|
|
Packit Service |
2b1f13 |
EDITRES_NAME, EDITRES_COMMAND_ATOM,
|
|
Packit Service |
2b1f13 |
EDITRES_PROTOCOL_ATOM, EDITRES_CLIENT_VALUE
|
|
Packit Service |
2b1f13 |
};
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
first_time = True;
|
|
Packit Service |
2b1f13 |
XInternAtoms(dpy, (char **) names, 4, False, atoms);
|
|
Packit Service |
2b1f13 |
res_editor = atoms[0];
|
|
Packit Service |
2b1f13 |
res_editor_command = atoms[1];
|
|
Packit Service |
2b1f13 |
res_editor_protocol = atoms[2];
|
|
Packit Service |
2b1f13 |
/* Used in later procedures */
|
|
Packit Service |
2b1f13 |
client_value = atoms[3];
|
|
Packit Service |
2b1f13 |
LoadResources(w);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((c_event->message_type != res_editor)
|
|
Packit Service |
2b1f13 |
|| (c_event->format != EDITRES_SEND_EVENT_FORMAT))
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
time = c_event->data.l[0];
|
|
Packit Service |
2b1f13 |
res_comm = c_event->data.l[1];
|
|
Packit Service |
2b1f13 |
ident = (ResIdent) c_event->data.l[2];
|
|
Packit Service |
2b1f13 |
if (c_event->data.l[3] != CURRENT_PROTOCOL_VERSION)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResResetStream(&globals.stream);
|
|
Packit Service |
2b1f13 |
_XEditResPut8(&globals.stream,
|
|
Packit Service |
2b1f13 |
(unsigned int) CURRENT_PROTOCOL_VERSION);
|
|
Packit Service |
2b1f13 |
SendCommand(w, res_comm, ident, ProtocolMismatch, &globals.stream);
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtGetSelectionValue(w, res_comm, res_editor_command,
|
|
Packit Service |
2b1f13 |
GetCommand, (XtPointer)(long)ident, time);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* BuildEvent
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to own selection, in case of error
|
|
Packit Service |
2b1f13 |
* sel - selection to send error message beck in
|
|
Packit Service |
2b1f13 |
* data - the data for the request
|
|
Packit Service |
2b1f13 |
* ident - the id number we are looking for
|
|
Packit Service |
2b1f13 |
* length - length of request
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Takes the info out the protocol stream an constructs
|
|
Packit Service |
2b1f13 |
* the proper event structure.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* the event, or NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
#if defined(ERROR_MESSAGE)
|
|
Packit Service |
2b1f13 |
#undef ERROR_MESSAGE
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#define ERROR_MESSAGE "Client: Improperly formatted protocol request"
|
|
Packit Service |
2b1f13 |
static EditresEvent *
|
|
Packit Service |
2b1f13 |
BuildEvent(Widget w, Atom sel, XtPointer data, ResIdent ident,
|
|
Packit Service |
2b1f13 |
unsigned long length)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
EditresEvent *event;
|
|
Packit Service |
2b1f13 |
ProtocolStream alloc_stream, *stream;
|
|
Packit Service |
2b1f13 |
unsigned char temp;
|
|
Packit Service |
2b1f13 |
register unsigned int i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
stream = &alloc_stream;
|
|
Packit Service |
2b1f13 |
stream->current = stream->top = (unsigned char *)data;
|
|
Packit Service |
2b1f13 |
stream->size = HEADER_SIZE; /* size of header */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Retrieve the Header
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (length < HEADER_SIZE)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident, ERROR_MESSAGE);
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
(void)_XEditResGet8(stream, &temp);
|
|
Packit Service |
2b1f13 |
if (temp != ident) /* Id's don't match, ignore request */
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
event = (EditresEvent *)XtCalloc(sizeof(EditresEvent), 1);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
(void)_XEditResGet8(stream, &temp);
|
|
Packit Service |
2b1f13 |
event->any_event.type = (EditresCommand)temp;
|
|
Packit Service |
2b1f13 |
(void)_XEditResGet32(stream, &stream->size);
|
|
Packit Service |
2b1f13 |
stream->top = stream->current; /* reset stream to top of value */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Now retrieve the data segment
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
switch(event->any_event.type)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
case SendWidgetTree:
|
|
Packit Service |
2b1f13 |
break; /* no additional info */
|
|
Packit Service |
2b1f13 |
case SetValues:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
SetValuesEvent *sv_event = (SetValuesEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(_XEditResGetString8(stream, &sv_event->name)
|
|
Packit Service |
2b1f13 |
&& _XEditResGetString8(stream, &sv_event->res_type)))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Since we need the value length, we have to pull the
|
|
Packit Service |
2b1f13 |
* value out by hand
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet16(stream, &sv_event->value_len))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
sv_event->value = XtMalloc(sizeof(char) * (sv_event->value_len + 1));
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < sv_event->value_len; i++)
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet8(stream, (unsigned char *)sv_event->value + i))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
((char*)sv_event->value)[i] = '\0';
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet16(stream, &sv_event->num_entries))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
sv_event->widgets = (WidgetInfo *)
|
|
Packit Service |
2b1f13 |
XtCalloc(sizeof(WidgetInfo), sv_event->num_entries);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < sv_event->num_entries; i++)
|
|
Packit Service |
2b1f13 |
if (!_XEditResGetWidgetInfo(stream, sv_event->widgets + i))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case FindChild:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
FindChildEvent *find_event = (FindChildEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
find_event->widgets = (WidgetInfo *)XtCalloc(sizeof(WidgetInfo), 1);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(_XEditResGetWidgetInfo(stream, find_event->widgets)
|
|
Packit Service |
2b1f13 |
&& _XEditResGetSigned16(stream, &find_event->x)
|
|
Packit Service |
2b1f13 |
&& _XEditResGetSigned16(stream, &find_event->y)))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case GetGeometry:
|
|
Packit Service |
2b1f13 |
case GetResources:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
GenericGetEvent *get_event = (GenericGetEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet16(stream, &get_event->num_entries))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
get_event->widgets = (WidgetInfo *)
|
|
Packit Service |
2b1f13 |
XtCalloc(sizeof(WidgetInfo), get_event->num_entries);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < get_event->num_entries; i++)
|
|
Packit Service |
2b1f13 |
if (!_XEditResGetWidgetInfo(stream, get_event->widgets + i))
|
|
Packit Service |
2b1f13 |
goto done;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case GetValues:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
GetValuesEvent *gv_event = (GetValuesEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResGetString8(stream, &gv_event->name);
|
|
Packit Service |
2b1f13 |
_XEditResGet16(stream, &gv_event->num_entries);
|
|
Packit Service |
2b1f13 |
gv_event->widgets = (WidgetInfo *)
|
|
Packit Service |
2b1f13 |
XtCalloc(sizeof(WidgetInfo), gv_event->num_entries);
|
|
Packit Service |
2b1f13 |
_XEditResGetWidgetInfo(stream, gv_event->widgets);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
default:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
char buf[BUFSIZ];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"Unknown Protocol request %d.", event->any_event.type);
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident, buf);
|
|
Packit Service |
2b1f13 |
FreeEvent(event);
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (event);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
done:
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident, ERROR_MESSAGE);
|
|
Packit Service |
2b1f13 |
FreeEvent(event);
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* FreeEvent
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* event - event to free
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Frees the event structure and any other pieces in it that need freeing.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
FreeEvent(EditresEvent *event)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (event->any_event.widgets != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree((char *)event->any_event.widgets->ids);
|
|
Packit Service |
2b1f13 |
XtFree((char *)event->any_event.widgets);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (event->any_event.type == SetValues)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree(event->set_values_event.name);
|
|
Packit Service |
2b1f13 |
XtFree(event->set_values_event.res_type);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)event);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* GetCommand
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* (See Xt XtConvertSelectionProc)
|
|
Packit Service |
2b1f13 |
* data - contains the ident number for the command
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Gets the Command out of the selection asserted by the resource manager.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
GetCommand(Widget w, XtPointer data, Atom *selection, Atom *type,
|
|
Packit Service |
2b1f13 |
XtPointer value, unsigned long *length, int *format)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
ResIdent ident = (ResIdent)(long)data;
|
|
Packit Service |
2b1f13 |
EditresEvent *event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (*type != res_editor_protocol || *format != EDITRES_FORMAT)
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((event = BuildEvent(w, *selection, value, ident, *length)) != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
ExecuteCommand(w, *selection, ident, event);
|
|
Packit Service |
2b1f13 |
FreeEvent(event);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* ExecuteCommand
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget
|
|
Packit Service |
2b1f13 |
* command - the command to execute
|
|
Packit Service |
2b1f13 |
* value - the associated with the command
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Executes a command string received from the resource editor.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
ExecuteCommand(Widget w, Atom sel, ResIdent ident, EditresEvent *event)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_Xconst char *(*func)(Widget, EditresEvent*, ProtocolStream*);
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (globals.block == BlockAll)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident,
|
|
Packit Service |
2b1f13 |
"This client has blocked all Editres commands.");
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else if (globals.block == BlockSetValues
|
|
Packit Service |
2b1f13 |
&& event->any_event.type == SetValues)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident,
|
|
Packit Service |
2b1f13 |
"This client has blocked all SetValues requests.");
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
switch(event->any_event.type)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
case SendWidgetTree:
|
|
Packit Service |
2b1f13 |
#if defined(LONG64) || defined(WORD64)
|
|
Packit Service |
2b1f13 |
globals.base_address = (unsigned long)w & 0xFFFFFFFF00000000;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
func = DumpWidgets;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case SetValues:
|
|
Packit Service |
2b1f13 |
func = DoSetValues;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case FindChild:
|
|
Packit Service |
2b1f13 |
func = DoFindChild;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case GetGeometry:
|
|
Packit Service |
2b1f13 |
func = DoGetGeometry;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case GetResources:
|
|
Packit Service |
2b1f13 |
func = DoGetResources;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case GetValues:
|
|
Packit Service |
2b1f13 |
func = DumpValues;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
default:
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
char buf[BUFSIZ];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"Unknown Protocol request %d.",event->any_event.type);
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident, buf);
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResResetStream(&globals.stream);
|
|
Packit Service |
2b1f13 |
if ((str = (*func)(w, event, &globals.stream)) == NULL)
|
|
Packit Service |
2b1f13 |
SendCommand(w, sel, ident, PartialSuccess, &globals.stream);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
SendFailure(w, sel, ident, str);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* ConvertReturnCommand
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - the widget that owns the selection
|
|
Packit Service |
2b1f13 |
* selection - selection to convert
|
|
Packit Service |
2b1f13 |
* target - target type for this selection
|
|
Packit Service |
2b1f13 |
* type_ret - type of the selection
|
|
Packit Service |
2b1f13 |
* value_ret - selection value
|
|
Packit Service |
2b1f13 |
* length_ret - lenght of this selection
|
|
Packit Service |
2b1f13 |
* format_ret - the format the selection is in
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Converts a selection
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if conversion was sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static Boolean
|
|
Packit Service |
2b1f13 |
ConvertReturnCommand(Widget w, Atom *selection, Atom *target, Atom *type_ret,
|
|
Packit Service |
2b1f13 |
XtPointer *value_ret, unsigned long *length_ret,
|
|
Packit Service |
2b1f13 |
int *format_ret)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* I assume the intrinsics give me the correct selection back
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if ((*target != client_value))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*type_ret = res_editor_protocol;
|
|
Packit Service |
2b1f13 |
*value_ret = (XtPointer)globals.command_stream->real_top;
|
|
Packit Service |
2b1f13 |
*length_ret = globals.command_stream->size + HEADER_SIZE;
|
|
Packit Service |
2b1f13 |
*format_ret = EDITRES_FORMAT;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* CommandDone
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* widget - unused
|
|
Packit Service |
2b1f13 |
* selection - unused
|
|
Packit Service |
2b1f13 |
* target - unused
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* done with the selection
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
CommandDone(Widget widget, Atom *selection, Atom *target)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
/* Keep the toolkit from automaticaly freeing the selection value */
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* SendFailure
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Paramters:
|
|
Packit Service |
2b1f13 |
* w - widget to own the selection
|
|
Packit Service |
2b1f13 |
* sel - selection to assert
|
|
Packit Service |
2b1f13 |
* ident - identifier
|
|
Packit Service |
2b1f13 |
* str - error message
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Sends a failure message
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
SendFailure(Widget w, Atom sel, ResIdent ident, _Xconst char *str)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResResetStream(&globals.stream);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(&globals.stream, str);
|
|
Packit Service |
2b1f13 |
SendCommand(w, sel, ident, Failure, &globals.stream);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* BuildReturnPacket
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* ident - identifier
|
|
Packit Service |
2b1f13 |
* command - command code
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Builds a return packet, given the data to send
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* packet to send
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static XtPointer
|
|
Packit Service |
2b1f13 |
BuildReturnPacket(ResIdent ident, EditResError error, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
long old_alloc, old_size;
|
|
Packit Service |
2b1f13 |
unsigned char *old_current;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* We have cleverly keep enough space at the top of the header
|
|
Packit Service |
2b1f13 |
* for the return protocol stream, so all we have to do is
|
|
Packit Service |
2b1f13 |
* fill in the space
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Fool the insert routines into putting the header in the right
|
|
Packit Service |
2b1f13 |
* place while being damn sure not to realloc (that would be very bad.)
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
old_current = stream->current;
|
|
Packit Service |
2b1f13 |
old_alloc = stream->alloc;
|
|
Packit Service |
2b1f13 |
old_size = stream->size;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
stream->current = stream->real_top;
|
|
Packit Service |
2b1f13 |
stream->alloc = stream->size + (2 * HEADER_SIZE);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, ident);
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, (unsigned char)error);
|
|
Packit Service |
2b1f13 |
_XEditResPut32(stream, old_size);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
stream->alloc = old_alloc;
|
|
Packit Service |
2b1f13 |
stream->current = old_current;
|
|
Packit Service |
2b1f13 |
stream->size = old_size;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return ((XtPointer)stream->real_top);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* SendCommand
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to own the selection
|
|
Packit Service |
2b1f13 |
* sel - selection to assert
|
|
Packit Service |
2b1f13 |
* ident - identifier
|
|
Packit Service |
2b1f13 |
* command - command code
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Builds a return command line
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
SendCommand(Widget w, Atom sel, ResIdent ident, EditResError error,
|
|
Packit Service |
2b1f13 |
ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
BuildReturnPacket(ident, error, stream);
|
|
Packit Service |
2b1f13 |
globals.command_stream = stream;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* I REALLY want to own the selection. Since this was not triggered
|
|
Packit Service |
2b1f13 |
* by a user action, and I am the only one using this atom it is safe to
|
|
Packit Service |
2b1f13 |
* use CurrentTime
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
XtOwnSelection(w, sel, CurrentTime, ConvertReturnCommand, NULL, CommandDone);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Generic Utility Functions
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
static int
|
|
Packit Service |
2b1f13 |
qcmp_widget_list(register _Xconst void *left, register _Xconst void *right)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
return (char *)*(Widget **)left - (char *)*(Widget **)right;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* FindChildren
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* parent - parent widget
|
|
Packit Service |
2b1f13 |
* children - list of children
|
|
Packit Service |
2b1f13 |
* normal - return normal children
|
|
Packit Service |
2b1f13 |
* popup - return popup children
|
|
Packit Service |
2b1f13 |
* extra - return extra children
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retuns all children (popup, normal and otherwise) of this widget
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* number of children
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static int
|
|
Packit Service |
2b1f13 |
FindChildren(Widget parent, Widget **children, Bool normal, Bool popup,
|
|
Packit Service |
2b1f13 |
Bool extra)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
CompositeWidget cw = (CompositeWidget)parent;
|
|
Packit Service |
2b1f13 |
Cardinal i, num_children, current = 0;
|
|
Packit Service |
2b1f13 |
Widget *extra_widgets = NULL;
|
|
Packit Service |
2b1f13 |
Cardinal num_extra = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
num_children = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsWidget(parent) && popup)
|
|
Packit Service |
2b1f13 |
num_children += parent->core.num_popups;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent) && normal)
|
|
Packit Service |
2b1f13 |
num_children += cw->composite.num_children;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsWidget(parent) && extra)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtResourceList norm_list, cons_list;
|
|
Packit Service |
2b1f13 |
Cardinal num_norm, num_cons;
|
|
Packit Service |
2b1f13 |
Arg args[1];
|
|
Packit Service |
2b1f13 |
Widget widget;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtGetResourceList(XtClass(parent), &norm_list, &num_norm);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtParent(parent) != NULL)
|
|
Packit Service |
2b1f13 |
XtGetConstraintResourceList(XtClass(XtParent(parent)),
|
|
Packit Service |
2b1f13 |
&cons_list, &num_cons);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
num_cons = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
extra_widgets = (Widget *)XtMalloc(sizeof(Widget));
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_norm; i++)
|
|
Packit Service |
2b1f13 |
if (strcmp(norm_list[i].resource_type, XtRWidget) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
widget = NULL;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], norm_list[i].resource_name, &widget);
|
|
Packit Service |
2b1f13 |
XtGetValues(parent, args, 1);
|
|
Packit Service |
2b1f13 |
if (widget && XtParent(widget) == parent)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
++num_extra;
|
|
Packit Service |
2b1f13 |
extra_widgets = (Widget *) XtRealloc(
|
|
Packit Service |
2b1f13 |
(char *)extra_widgets, num_extra * sizeof(Widget));
|
|
Packit Service |
2b1f13 |
extra_widgets[num_extra - 1] = widget;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_cons; i++)
|
|
Packit Service |
2b1f13 |
if (strcmp(cons_list[i].resource_type, XtRWidget) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
widget = NULL;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], cons_list[i].resource_name, &widget);
|
|
Packit Service |
2b1f13 |
XtGetValues(parent, args, 1);
|
|
Packit Service |
2b1f13 |
if (widget && XtParent(widget) == parent)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
++num_extra;
|
|
Packit Service |
2b1f13 |
extra_widgets = (Widget *) XtRealloc(
|
|
Packit Service |
2b1f13 |
(char *)extra_widgets, num_extra * sizeof(Widget));
|
|
Packit Service |
2b1f13 |
extra_widgets[num_extra - 1] = widget;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
if (num_norm)
|
|
Packit Service |
2b1f13 |
XtFree((char *)norm_list);
|
|
Packit Service |
2b1f13 |
if (num_cons)
|
|
Packit Service |
2b1f13 |
XtFree((char *)cons_list);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((num_children + num_extra) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
*children = NULL;
|
|
Packit Service |
2b1f13 |
return (0);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*children = (Widget *)XtMalloc(sizeof(Widget) * (num_children + num_extra));
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsComposite(parent) && normal)
|
|
Packit Service |
2b1f13 |
for (i = 0; i < cw->composite.num_children; i++, current++)
|
|
Packit Service |
2b1f13 |
(*children)[current] = cw->composite.children[i];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsWidget(parent) && popup)
|
|
Packit Service |
2b1f13 |
for (i = 0; i < parent->core.num_popups; i++, current++)
|
|
Packit Service |
2b1f13 |
(*children)[current] = parent->core.popup_list[i];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (num_extra)
|
|
Packit Service |
2b1f13 |
/* Check for dups */
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Cardinal j, old_num_extra = num_extra;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
qsort(extra_widgets, num_extra, sizeof(Widget), qcmp_widget_list);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_extra - 1; i++)
|
|
Packit Service |
2b1f13 |
while (i < num_extra - 1 &&
|
|
Packit Service |
2b1f13 |
extra_widgets[i] == extra_widgets[i + 1])
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
memmove(&extra_widgets[i], &extra_widgets[i + 1],
|
|
Packit Service |
2b1f13 |
(num_extra - i) * sizeof(Widget));
|
|
Packit Service |
2b1f13 |
--num_extra;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_children; i++)
|
|
Packit Service |
2b1f13 |
for (j = 0; j < num_extra; j++)
|
|
Packit Service |
2b1f13 |
if ((*children)[i] == extra_widgets[j])
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if ((j + 1) < num_extra)
|
|
Packit Service |
2b1f13 |
memmove(&extra_widgets[j], &extra_widgets[j + 1],
|
|
Packit Service |
2b1f13 |
(num_extra - j) * sizeof(Widget));
|
|
Packit Service |
2b1f13 |
--num_extra;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (old_num_extra != num_extra)
|
|
Packit Service |
2b1f13 |
*children = (Widget *)XtRealloc((char *)*children, sizeof(Widget)
|
|
Packit Service |
2b1f13 |
* (num_children + num_extra));
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (num_extra)
|
|
Packit Service |
2b1f13 |
memcpy(&(*children)[num_children], extra_widgets,
|
|
Packit Service |
2b1f13 |
sizeof(Widget) * num_extra);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
if (extra_widgets)
|
|
Packit Service |
2b1f13 |
XtFree((char *)extra_widgets);
|
|
Packit Service |
2b1f13 |
if (num_children + num_extra == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree((char *)*children);
|
|
Packit Service |
2b1f13 |
*children = NULL;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (num_children + num_extra);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* IsChild
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* parameters:
|
|
Packit Service |
2b1f13 |
* top - top of the tree
|
|
Packit Service |
2b1f13 |
* parent - parent widget
|
|
Packit Service |
2b1f13 |
* child - child widget
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Check to see of child is a child of parent
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Bool
|
|
Packit Service |
2b1f13 |
IsChild(Widget top, Widget parent, Widget child)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int i, num_children;
|
|
Packit Service |
2b1f13 |
Widget *children;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (parent == NULL)
|
|
Packit Service |
2b1f13 |
return (top == child);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
num_children = FindChildren(parent, &children, True, True, True);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_children; i++)
|
|
Packit Service |
2b1f13 |
if (children[i] == child)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree((char *)children);
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)children);
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* VerifyWidget
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - any widget in the tree
|
|
Packit Service |
2b1f13 |
* info - info about the widget to verify
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Makes sure all the widgets still exist
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
VerifyWidget(Widget w, WidgetInfo *info)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Widget top;
|
|
Packit Service |
2b1f13 |
register int count;
|
|
Packit Service |
2b1f13 |
register Widget parent;
|
|
Packit Service |
2b1f13 |
register unsigned long *child;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (top = w; XtParent(top) != NULL; top = XtParent(top))
|
|
Packit Service |
2b1f13 |
;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
parent = NULL;
|
|
Packit Service |
2b1f13 |
child = info->ids;
|
|
Packit Service |
2b1f13 |
count = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
while (True)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (!IsChild(top, parent, (Widget) *child))
|
|
Packit Service |
2b1f13 |
return ("This widget no longer exists in the client.");
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (++count == info->num_widgets)
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
parent = (Widget)*child++;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
info->real_widget = (Widget)*child;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code to Perform SetValues operations
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DoSetValues
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - a widget in the tree
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Performs the setvalues requested
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DoSetValues(Widget w, EditresEvent *event, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
register unsigned i;
|
|
Packit Service |
2b1f13 |
unsigned short count = 0;
|
|
Packit Service |
2b1f13 |
SetValuesEvent *sv_event = (SetValuesEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, count); /* insert 0, will be overwritten later */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < sv_event->num_entries; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if ((str = VerifyWidget(w, &sv_event->widgets[i])) != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutWidgetInfo(stream, &sv_event->widgets[i]);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, str);
|
|
Packit Service |
2b1f13 |
count++;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
ExecuteSetValues(sv_event->widgets[i].real_widget,
|
|
Packit Service |
2b1f13 |
sv_event, sv_event->widgets + i, stream, &count);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Overwrite the first 2 bytes with the real count.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
*(stream->top) = count >> XER_NBBY;
|
|
Packit Service |
2b1f13 |
*(stream->top + 1) = count;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* HandleToolkitErrors
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* name - name of the error
|
|
Packit Service |
2b1f13 |
* type - type of the error
|
|
Packit Service |
2b1f13 |
* class - class of the error
|
|
Packit Service |
2b1f13 |
* msg - the default message
|
|
Packit Service |
2b1f13 |
* params - the extra parameters for this message
|
|
Packit Service |
2b1f13 |
* num_params - ""
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description: Handles X Toolkit Errors.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/* ARGSUSED */
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
HandleToolkitErrors(String name, String type, String class, String msg,
|
|
Packit Service |
2b1f13 |
String *params, Cardinal *num_params)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
SVErrorInfo *info = &globals.error_info;
|
|
Packit Service |
2b1f13 |
char buf[BUFSIZ];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (streq(name, "unknownType"))
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"The `%s' resource is not used by this widget.",
|
|
Packit Service |
2b1f13 |
info->event->name);
|
|
Packit Service |
2b1f13 |
else if (streq(name, "noColormap"))
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf), msg, params[0]);
|
|
Packit Service |
2b1f13 |
else if (streq(name, "conversionFailed") || streq(name, "conversionError"))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (streq((String)info->event->value, XtRString))
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"Could not convert the string '%s' for the `%s' "
|
|
Packit Service |
2b1f13 |
"resource.", (String)info->event->value,
|
|
Packit Service |
2b1f13 |
info->event->name);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"Could not convert the `%s' resource.",
|
|
Packit Service |
2b1f13 |
info->event->name);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buf, sizeof(buf),
|
|
Packit Service |
2b1f13 |
"Name: %s, Type: %s, Class: %s, Msg: %s",
|
|
Packit Service |
2b1f13 |
name, type, class, msg);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Insert this info into the protocol stream, and update the count
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
(*(info->count))++;
|
|
Packit Service |
2b1f13 |
_XEditResPutWidgetInfo(info->stream, info->entry);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(info->stream, buf);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* ExecuteSetValues
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to perform the set_values on
|
|
Packit Service |
2b1f13 |
* sv_event - set values event
|
|
Packit Service |
2b1f13 |
* sv_info - set_value info
|
|
Packit Service |
2b1f13 |
*.
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Performs a setvalues for a given command
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
ExecuteSetValues(Widget w, SetValuesEvent *sv_event, WidgetInfo *entry,
|
|
Packit Service |
2b1f13 |
ProtocolStream *stream, unsigned short *count)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtErrorMsgHandler old;
|
|
Packit Service |
2b1f13 |
SVErrorInfo *info = &globals.error_info;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
info->event = sv_event; /* No data can be passed to */
|
|
Packit Service |
2b1f13 |
info->stream = stream; /* an error handler, so we */
|
|
Packit Service |
2b1f13 |
info->count = count; /* have to use a global */
|
|
Packit Service |
2b1f13 |
info->entry = entry;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
old = XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w),
|
|
Packit Service |
2b1f13 |
HandleToolkitErrors);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtVaSetValues(w, XtVaTypedArg,
|
|
Packit Service |
2b1f13 |
sv_event->name, sv_event->res_type,
|
|
Packit Service |
2b1f13 |
sv_event->value, sv_event->value_len,
|
|
Packit Service |
2b1f13 |
NULL);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
(void)XtAppSetWarningMsgHandler(XtWidgetToApplicationContext(w), old);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for Creating and dumping widget tree.
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/* Function:
|
|
Packit Service |
2b1f13 |
* DumpWidgets
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - a widget in the tree
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Given a widget it builds a protocol packet containing the entire
|
|
Packit Service |
2b1f13 |
* widget heirarchy.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
#define TOOLKIT_TYPE ("Xt")
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DumpWidgets(Widget w, EditresEvent *event, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned short count = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* Find Tree's root */
|
|
Packit Service |
2b1f13 |
for (; XtParent(w) != NULL; w = XtParent(w))
|
|
Packit Service |
2b1f13 |
;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* hold space for count, overwritten later
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, (unsigned int)0);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
DumpChildren(w, stream, &count);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* write out toolkit type
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, TOOLKIT_TYPE);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Overwrite the first 2 bytes with the real count
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
*(stream->top) = count >> XER_NBBY;
|
|
Packit Service |
2b1f13 |
*(stream->top + 1) = count;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DumpChildren
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to dump
|
|
Packit Service |
2b1f13 |
* stream - stream to dump to
|
|
Packit Service |
2b1f13 |
* count - number of dumps we have performed
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Adds a child's name to the list.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/* This is a trick/kludge. To make shared libraries happier (linking
|
|
Packit Service |
2b1f13 |
* against Xmu but not linking against Xt, and apparently even work
|
|
Packit Service |
2b1f13 |
* as we desire on SVR4, we need to avoid an explicit data reference
|
|
Packit Service |
2b1f13 |
* to applicationShellWidgetClass. XtIsTopLevelShell is known
|
|
Packit Service |
2b1f13 |
* (implementation dependent assumption!) to use a bit flag. So we
|
|
Packit Service |
2b1f13 |
* go that far. Then, we test whether it is an applicationShellWidget
|
|
Packit Service |
2b1f13 |
* class by looking for an explicit class name. Seems pretty safe.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Bool
|
|
Packit Service |
2b1f13 |
isApplicationShell(Widget w)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
register WidgetClass c;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!XtIsTopLevelShell(w))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
for (c = XtClass(w); c; c = c->core_class.superclass)
|
|
Packit Service |
2b1f13 |
if (strcmp(c->core_class.class_name, "ApplicationShell") == 0)
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
DumpChildren(Widget w, ProtocolStream *stream, unsigned short *count)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int i, num_children;
|
|
Packit Service |
2b1f13 |
Widget *children;
|
|
Packit Service |
2b1f13 |
unsigned long window;
|
|
Packit Service |
2b1f13 |
char *c_class;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
(*count)++;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
InsertWidget(stream, w); /* Insert the widget into the stream */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, XtName(w)); /* Insert name */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (isApplicationShell(w))
|
|
Packit Service |
2b1f13 |
c_class = ((ApplicationShellWidget)w)->application.class;
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
c_class = XtClass(w)->core_class.class_name;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, c_class); /* Insert class */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtIsWidget(w))
|
|
Packit Service |
2b1f13 |
if (XtIsRealized(w))
|
|
Packit Service |
2b1f13 |
window = XtWindow(w);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
window = EDITRES_IS_UNREALIZED;
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
window = EDITRES_IS_OBJECT;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut32(stream, window); /* Insert window id */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Find children and recurse
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
num_children = FindChildren(w, &children, True, True, True);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_children; i++)
|
|
Packit Service |
2b1f13 |
DumpChildren(children[i], stream, count);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)children);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for getting the geometry of widgets
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DoGetGeometry
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget in the tree
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves the Geometry of each specified widget.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DoGetGeometry(Widget w, EditresEvent *event, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned i;
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
GetGeomEvent *geom_event = (GetGeomEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, geom_event->num_entries);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < geom_event->num_entries; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Send out the widget id
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
_XEditResPutWidgetInfo(stream, &geom_event->widgets[i]);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((str = VerifyWidget(w, &geom_event->widgets[i])) != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, True); /* an error occured */
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, str); /* set message */
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
ExecuteGetGeometry(geom_event->widgets[i].real_widget, stream);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* ExecuteGetGeometry
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to get geometry
|
|
Packit Service |
2b1f13 |
* stream - stream to append to
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Gets the geometry for each widget specified.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if no error occured.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
ExecuteGetGeometry(Widget w, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int i;
|
|
Packit Service |
2b1f13 |
Boolean mapped_when_man;
|
|
Packit Service |
2b1f13 |
Dimension width, height, border_width;
|
|
Packit Service |
2b1f13 |
Arg args[8];
|
|
Packit Service |
2b1f13 |
Cardinal num_args = 0;
|
|
Packit Service |
2b1f13 |
Position x, y;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!XtIsRectObj(w) || (XtIsWidget(w) && !XtIsRealized(w)))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* no error */
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* not visable */
|
|
Packit Service |
2b1f13 |
for (i = 0; i < 5; i++) /* fill in extra space with 0's */
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, 0);
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num_args], XtNwidth, &width); num_args++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num_args], XtNheight, &height); num_args++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num_args], XtNborderWidth, &border_width); num_args++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num_args], XtNmappedWhenManaged, &mapped_when_man);
|
|
Packit Service |
2b1f13 |
num_args++;
|
|
Packit Service |
2b1f13 |
XtGetValues(w, args, num_args);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(XtIsManaged(w) && mapped_when_man) && XtIsWidget(w))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XWindowAttributes attrs;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* The toolkit does not maintain mapping state, we have
|
|
Packit Service |
2b1f13 |
* to go to the server
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (XGetWindowAttributes(XtDisplay(w), XtWindow(w), &attrs) != 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (attrs.map_state != IsViewable)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* no error */
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* not visable */
|
|
Packit Service |
2b1f13 |
for (i = 0; i < 5; i++) /* fill in extra space with 0's */
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, 0);
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, True); /* Error occured. */
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, "XGetWindowAttributes failed.");
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtTranslateCoords(w, -((int) border_width), -((int) border_width), &x, &y);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* no error */
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, True); /* Visable */
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, x);
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, y);
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, width);
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, height);
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, border_width);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for executing FindChild
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* PositionInChild
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* child - child widget to check
|
|
Packit Service |
2b1f13 |
* x - location of point to check in the parent's coord space
|
|
Packit Service |
2b1f13 |
* y - ""
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Returns true if this location is in the child.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Bool
|
|
Packit Service |
2b1f13 |
PositionInChild(Widget child, int x, int y)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Arg args[6];
|
|
Packit Service |
2b1f13 |
Cardinal num;
|
|
Packit Service |
2b1f13 |
Dimension width, height, border_width;
|
|
Packit Service |
2b1f13 |
Position child_x, child_y;
|
|
Packit Service |
2b1f13 |
Boolean mapped_when_managed;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!XtIsRectObj(child)) /* we must at least be a rect obj */
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
num = 0;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNmappedWhenManaged, &mapped_when_managed); num++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNwidth, &width); num++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNheight, &height); num++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNx, &child_x); num++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNy, &child_y); num++;
|
|
Packit Service |
2b1f13 |
XtSetArg(args[num], XtNborderWidth, &border_width); num++;
|
|
Packit Service |
2b1f13 |
XtGetValues(child, args, num);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* The only way we will know of the widget is mapped is to see if
|
|
Packit Service |
2b1f13 |
* mapped when managed is True and this is a managed child. Otherwise
|
|
Packit Service |
2b1f13 |
* we will have to ask the server if this window is mapped
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (XtIsWidget(child) && !(mapped_when_managed && XtIsManaged(child)))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XWindowAttributes attrs;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XGetWindowAttributes(XtDisplay(child), XtWindow(child), &attrs)
|
|
Packit Service |
2b1f13 |
&& attrs.map_state != IsViewable)
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return ((x >= child_x)
|
|
Packit Service |
2b1f13 |
&& (x <= (child_x + (Position)width + 2 * (Position)border_width))
|
|
Packit Service |
2b1f13 |
&& (y >= child_y)
|
|
Packit Service |
2b1f13 |
&& (y <= (child_y + (Position)height + 2 * (Position)border_width)));
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _FindChild
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* parent - widget that is known to contain the point specified
|
|
Packit Service |
2b1f13 |
* x - point in coordinates relative to the widget specified
|
|
Packit Service |
2b1f13 |
* y - ""
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Finds the child that actually contains the point shown.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Widget
|
|
Packit Service |
2b1f13 |
_FindChild(Widget parent, int x, int y)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Widget *children;
|
|
Packit Service |
2b1f13 |
int i = FindChildren(parent, &children, True, False, True);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
while (i > 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
i--;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (PositionInChild(children[i], x, y))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Widget child = children[i];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)children);
|
|
Packit Service |
2b1f13 |
return (_FindChild(child, x - child->core.x, y - child->core.y));
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)children);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (parent);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DoFindChild
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget in the tree
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Finds the child that contains the location specified.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* An allocated error message if something went horribly wrong and
|
|
Packit Service |
2b1f13 |
* no set values were performed, else NULL.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DoFindChild(Widget w, EditresEvent *event, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
Widget parent, child;
|
|
Packit Service |
2b1f13 |
Position parent_x, parent_y;
|
|
Packit Service |
2b1f13 |
FindChildEvent *find_event = (FindChildEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((str = VerifyWidget(w, find_event->widgets)) != NULL)
|
|
Packit Service |
2b1f13 |
return (str);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
parent = find_event->widgets->real_widget;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtTranslateCoords(parent, (Position) 0, (Position) 0,
|
|
Packit Service |
2b1f13 |
&parent_x, &parent_y);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
child = _FindChild(parent, find_event->x - (int) parent_x,
|
|
Packit Service |
2b1f13 |
find_event->y - (int) parent_y);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
InsertWidget(stream, child);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Procedures for performing GetResources
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DoGetResources
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget in the tree
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Gets the Resources associated with the widgets passed.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DoGetResources(Widget w, EditresEvent *event, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned int i;
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
GetResEvent *res_event = (GetResEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, res_event->num_entries); /* number of replys */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < res_event->num_entries; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Send out the widget id
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
_XEditResPutWidgetInfo(stream, &res_event->widgets[i]);
|
|
Packit Service |
2b1f13 |
if ((str = VerifyWidget(w, &res_event->widgets[i])) != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, True); /* an error occured */
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, str); /* set message */
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutBool(stream, False); /* no error occured */
|
|
Packit Service |
2b1f13 |
ExecuteGetResources(res_event->widgets[i].real_widget, stream);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* Function:
|
|
Packit Service |
2b1f13 |
* ExecuteGetResources
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget to get resources on
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Gets the resources for any individual widget
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
ExecuteGetResources(Widget w, ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtResourceList norm_list, cons_list;
|
|
Packit Service |
2b1f13 |
Cardinal num_norm, num_cons;
|
|
Packit Service |
2b1f13 |
register Cardinal i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Get Normal Resources
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
XtGetResourceList(XtClass(w), &norm_list, &num_norm);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtParent(w) != NULL)
|
|
Packit Service |
2b1f13 |
XtGetConstraintResourceList(XtClass(XtParent(w)), &cons_list,&num_cons);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
num_cons = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, num_norm + num_cons); /* how many resources */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Insert all the normal resources
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_norm; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutResourceType(stream, NormalResource);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, norm_list[i].resource_name);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, norm_list[i].resource_class);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, norm_list[i].resource_type);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
XtFree((char *)norm_list);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Insert all the constraint resources
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (num_cons > 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_cons; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPutResourceType(stream, ConstraintResource);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, cons_list[i].resource_name);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, cons_list[i].resource_class);
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, cons_list[i].resource_type);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
XtFree((char *)cons_list);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* DumpValues
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* event - event that caused this action
|
|
Packit Service |
2b1f13 |
* stream - protocol stream to add
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Returns resource values to the resource editor.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* NULL
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static _Xconst char *
|
|
Packit Service |
2b1f13 |
DumpValues(Widget w, EditresEvent* event, ProtocolStream* stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_Xconst char *str;
|
|
Packit Service |
2b1f13 |
Arg warg[1];
|
|
Packit Service |
2b1f13 |
_Xconst _XtString res_value = NULL;
|
|
Packit Service |
2b1f13 |
GetValuesEvent *gv_event = (GetValuesEvent *)event;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* put the count in the stream */
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, (unsigned int)1);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Get the resource of the widget asked for by the
|
|
Packit Service |
2b1f13 |
* resource editor and insert it into the stream
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
XtSetArg(warg[0], gv_event->name, &res_value);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if ((str = VerifyWidget(w, &gv_event->widgets[0])) != NULL)
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, str);
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditresGetStringValues(gv_event->widgets[0].real_widget, warg, 1);
|
|
Packit Service |
2b1f13 |
if (!res_value)
|
|
Packit Service |
2b1f13 |
res_value = "NoValue";
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(stream, res_value);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (NULL);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for inserting values into the protocol stream
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* InsertWidget
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* w - widget to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts the full parent hierarchy of this widget into the protocol
|
|
Packit Service |
2b1f13 |
* stream as a widget list.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
InsertWidget(ProtocolStream *stream, Widget w)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Widget temp;
|
|
Packit Service |
2b1f13 |
unsigned long *widget_list;
|
|
Packit Service |
2b1f13 |
register int i, num_widgets;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (temp = w, i = 0; temp != NULL; temp = XtParent(temp), i++)
|
|
Packit Service |
2b1f13 |
;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
num_widgets = i;
|
|
Packit Service |
2b1f13 |
widget_list = (unsigned long *)XtMalloc(sizeof(unsigned long) * num_widgets);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Put the widgets into the list
|
|
Packit Service |
2b1f13 |
* make sure that they are inserted in the list from parent -> child
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
for (i--, temp = w; temp != NULL; temp = XtParent(temp), i--)
|
|
Packit Service |
2b1f13 |
widget_list[i] = (unsigned long)temp;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, num_widgets); /* insert number of widgets */
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_widgets; i++) /* insert Widgets themselves */
|
|
Packit Service |
2b1f13 |
_XEditResPut32(stream, widget_list[i]);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)widget_list);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* All of the following routines are public
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResPutString8
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - stream to insert string into
|
|
Packit Service |
2b1f13 |
* str - string to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts a string into the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResPutString8(ProtocolStream *stream, _Xconst char *str)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int i, len = strlen(str);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, len);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < len; i++, str++)
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, *str);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResPut8
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - stream to insert string into
|
|
Packit Service |
2b1f13 |
* value - value to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts an 8 bit integer into the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResPut8(ProtocolStream *stream, unsigned int value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char temp;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (stream->size >= stream->alloc)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
stream->alloc += 100;
|
|
Packit Service |
2b1f13 |
stream->real_top = (unsigned char *)
|
|
Packit Service |
2b1f13 |
XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
|
|
Packit Service |
2b1f13 |
stream->top = stream->real_top + HEADER_SIZE;
|
|
Packit Service |
2b1f13 |
stream->current = stream->top + stream->size;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
temp = (unsigned char) (value & BYTE_MASK);
|
|
Packit Service |
2b1f13 |
*((stream->current)++) = temp;
|
|
Packit Service |
2b1f13 |
(stream->size)++;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResPut16
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Arguments:
|
|
Packit Service |
2b1f13 |
* stream - stream to insert string into
|
|
Packit Service |
2b1f13 |
* value - value to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts a 16 bit integer into the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResPut16(ProtocolStream *stream, unsigned int value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, (value >> XER_NBBY) & BYTE_MASK);
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, value & BYTE_MASK);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResPut32
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Arguments:
|
|
Packit Service |
2b1f13 |
* stream - stream to insert string into
|
|
Packit Service |
2b1f13 |
* value - value to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts a 32 bit integer into the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResPut32(ProtocolStream *stream, unsigned long value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
int i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 3; i >= 0; i--)
|
|
Packit Service |
2b1f13 |
_XEditResPut8(stream, (value >> (XER_NBBY * i)) & BYTE_MASK);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResPutWidgetInfo
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - stream to insert widget info into
|
|
Packit Service |
2b1f13 |
* info - info to insert
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Inserts the widget info into the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResPutWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned int i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
_XEditResPut16(stream, info->num_widgets);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < info->num_widgets; i++)
|
|
Packit Service |
2b1f13 |
_XEditResPut32(stream, info->ids[i]);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for retrieving values from the protocol stream
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResResetStream
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - stream to reset
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Resets the protocol stream.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
void
|
|
Packit Service |
2b1f13 |
_XEditResResetStream(ProtocolStream *stream)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
stream->current = stream->top;
|
|
Packit Service |
2b1f13 |
stream->size = 0;
|
|
Packit Service |
2b1f13 |
if (stream->real_top == NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
stream->real_top = (unsigned char *)
|
|
Packit Service |
2b1f13 |
XtRealloc((char *)stream->real_top, stream->alloc + HEADER_SIZE);
|
|
Packit Service |
2b1f13 |
stream->top = stream->real_top + HEADER_SIZE;
|
|
Packit Service |
2b1f13 |
stream->current = stream->top + stream->size;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* The only modified field if the "current" field
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* The only fields that must be set correctly are the "current", "top"
|
|
Packit Service |
2b1f13 |
* and "size" fields.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGetg8
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* value - a pointer to value to return
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves an unsigned 8 bit value from the protocol stream.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGet8(ProtocolStream *stream, unsigned char *value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (stream->size < (unsigned long)(stream->current - stream->top))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*value = *((stream->current)++);
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGet16
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* value - pointer to return value
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves an unsigned 16 bit value from the protocol stream.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGet16(ProtocolStream *stream, unsigned short *value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char temp1, temp2;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGetSigned16
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* value - pointer to return value
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves an signed 16 bit value from the protocol stream.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGetSigned16(ProtocolStream *stream, short *value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned char temp1, temp2;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(_XEditResGet8(stream, &temp1) && _XEditResGet8(stream, &temp2)))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (temp1 & (1 << (XER_NBBY - 1))) /* If the sign bit is active */
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
*value = -1; /* store all 1's */
|
|
Packit Service |
2b1f13 |
*value &= (temp1 << XER_NBBY); /* Now and in the MSB */
|
|
Packit Service |
2b1f13 |
*value &= temp2; /* and LSB */
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
*value = ((unsigned short)temp1 << XER_NBBY) + (unsigned short)temp2;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGet32
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* value - pointer to return value
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves an unsigned 32 bit value from the protocol stream.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGet32(ProtocolStream *stream, unsigned long *value)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned short temp1, temp2;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!(_XEditResGet16(stream, &temp1) && _XEditResGet16(stream, &temp2)))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*value = ((unsigned short)temp1 << (XER_NBBY * 2)) + (unsigned short)temp2;
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGetString8
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* str - string to retrieve
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves an 8 bit string value from the protocol stream.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if retrieval was successful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGetString8(ProtocolStream *stream, char **str)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned short len;
|
|
Packit Service |
2b1f13 |
register unsigned i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet16(stream, &len))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*str = XtMalloc(sizeof(char) * (len + 1));
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < len; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet8(stream, (unsigned char *)*str + i))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree(*str);
|
|
Packit Service |
2b1f13 |
*str = NULL;
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
(*str)[i] = '\0';
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditResGetWidgetInfo
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* stream - protocol stream
|
|
Packit Service |
2b1f13 |
* info - widget info struct to store into
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Retrieves the list of widgets that follow and stores them in the
|
|
Packit Service |
2b1f13 |
* widget info structure provided.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if retrieval was successful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
Bool
|
|
Packit Service |
2b1f13 |
_XEditResGetWidgetInfo(ProtocolStream *stream, WidgetInfo *info)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
unsigned int i;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet16(stream, &info->num_widgets))
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
info->ids = (unsigned long *)XtMalloc(sizeof(long) * info->num_widgets);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (i = 0; i < info->num_widgets; i++)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (!_XEditResGet32(stream, info->ids + i))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree((char *)info->ids);
|
|
Packit Service |
2b1f13 |
info->ids = NULL;
|
|
Packit Service |
2b1f13 |
return (False);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
#if defined(LONG64) || defined(WORD64)
|
|
Packit Service |
2b1f13 |
info->ids[i] |= globals.base_address;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
return (True);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/************************************************************
|
|
Packit Service |
2b1f13 |
* Code for Loading the EditresBlock resource
|
|
Packit Service |
2b1f13 |
************************************************************/
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* CvStringToBlock
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* dpy - display
|
|
Packit Service |
2b1f13 |
* args - unused
|
|
Packit Service |
2b1f13 |
* num_args - unused
|
|
Packit Service |
2b1f13 |
* from_val - value to convert
|
|
Packit Service |
2b1f13 |
* to_val - where to store
|
|
Packit Service |
2b1f13 |
* converter_data - unused
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Converts a string to an editres block value.
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Returns:
|
|
Packit Service |
2b1f13 |
* True if conversion was sucessful
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static Boolean
|
|
Packit Service |
2b1f13 |
CvtStringToBlock(Display *dpy, XrmValue *args, Cardinal *num_args,
|
|
Packit Service |
2b1f13 |
XrmValue *from_val, XrmValue *to_val,
|
|
Packit Service |
2b1f13 |
XtPointer *converter_data)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
char ptr[16];
|
|
Packit Service |
2b1f13 |
static EditresBlock block;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XmuNCopyISOLatin1Lowered(ptr, from_val->addr, sizeof(ptr));
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (streq(ptr, "none"))
|
|
Packit Service |
2b1f13 |
block = BlockNone;
|
|
Packit Service |
2b1f13 |
else if (streq(ptr, "setvalues"))
|
|
Packit Service |
2b1f13 |
block = BlockSetValues;
|
|
Packit Service |
2b1f13 |
else if (streq(ptr, "all"))
|
|
Packit Service |
2b1f13 |
block = BlockAll;
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Cardinal num_params = 1;
|
|
Packit Service |
2b1f13 |
String params[1];
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
params[0] = from_val->addr;
|
|
Packit Service |
2b1f13 |
XtAppWarningMsg(XtDisplayToApplicationContext(dpy),
|
|
Packit Service |
2b1f13 |
"CvtStringToBlock", "unknownValue", "EditresError",
|
|
Packit Service |
2b1f13 |
"Could not convert string \"%s\" to EditresBlock.",
|
|
Packit Service |
2b1f13 |
params, &num_params);
|
|
Packit Service |
2b1f13 |
return FALSE;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (to_val->addr != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (to_val->size < sizeof(EditresBlock))
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
to_val->size = sizeof(EditresBlock);
|
|
Packit Service |
2b1f13 |
return FALSE;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
*(EditresBlock *)(to_val->addr) = block;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
to_val->addr = (XtPointer)block;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
to_val->size = sizeof(EditresBlock);
|
|
Packit Service |
2b1f13 |
return TRUE;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#define XtREditresBlock "EditresBlock"
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* LoadResources
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - any widget in the tree
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Description:
|
|
Packit Service |
2b1f13 |
* Loads a global resource the determines of this application should
|
|
Packit Service |
2b1f13 |
* allow Editres requests.
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
LoadResources(Widget w)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
static XtResource resources[] = {
|
|
Packit Service |
2b1f13 |
{"editresBlock", "EditresBlock", XtREditresBlock, sizeof(EditresBlock),
|
|
Packit Service |
2b1f13 |
XtOffsetOf(Globals, block), XtRImmediate, (XtPointer)BlockNone}
|
|
Packit Service |
2b1f13 |
};
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
for (; XtParent(w) != NULL; w = XtParent(w))
|
|
Packit Service |
2b1f13 |
;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtAppSetTypeConverter(XtWidgetToApplicationContext(w),
|
|
Packit Service |
2b1f13 |
XtRString, XtREditresBlock, CvtStringToBlock,
|
|
Packit Service |
2b1f13 |
NULL, 0, XtCacheAll, NULL);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtGetApplicationResources(w, (XtPointer)&globals, resources,
|
|
Packit Service |
2b1f13 |
XtNumber(resources), NULL, 0);
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Function:
|
|
Packit Service |
2b1f13 |
* _XEditresGetStringValues
|
|
Packit Service |
2b1f13 |
*
|
|
Packit Service |
2b1f13 |
* Parameters:
|
|
Packit Service |
2b1f13 |
* w - widget
|
|
Packit Service |
2b1f13 |
* warg - where to store result
|
|
Packit Service |
2b1f13 |
* numargs - unused
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
/*ARGSUSED*/
|
|
Packit Service |
2b1f13 |
static void
|
|
Packit Service |
2b1f13 |
_XEditresGetStringValues(Widget w, Arg *warg, int numargs)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
static char buffer[32];
|
|
Packit Service |
2b1f13 |
XtResourceList res_list;
|
|
Packit Service |
2b1f13 |
Cardinal num_res;
|
|
Packit Service |
2b1f13 |
XtResource *res = NULL;
|
|
Packit Service |
2b1f13 |
long value;
|
|
Packit Service |
2b1f13 |
Cardinal i;
|
|
Packit Service |
2b1f13 |
char *string = "";
|
|
Packit Service |
2b1f13 |
Arg args[1];
|
|
Packit Service |
2b1f13 |
XrmValue to, from;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Look for the resource
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
XtGetResourceList(XtClass(w), &res_list, &num_res);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_res; i++)
|
|
Packit Service |
2b1f13 |
if (strcmp(res_list[i].resource_name, warg->name) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
res = &res_list[i];
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (res == NULL && XtParent(w) != NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
XtFree((char *)res_list);
|
|
Packit Service |
2b1f13 |
XtGetConstraintResourceList(XtClass(XtParent(w)), &res_list, &num_res);
|
|
Packit Service |
2b1f13 |
for (i = 0; i < num_res; i++)
|
|
Packit Service |
2b1f13 |
if (strcmp(res_list[i].resource_name, warg->name) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
res = &res_list[i];
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (res == NULL)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
/* Couldn't find resource */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
XtFree((char *)res_list);
|
|
Packit Service |
2b1f13 |
*(XtPointer *)warg->value = NULL;
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* try to get the value in the proper size */
|
|
Packit Service |
2b1f13 |
switch (res->resource_size)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
#ifdef LONG64
|
|
Packit Service |
2b1f13 |
long v8;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
int v4;
|
|
Packit Service |
2b1f13 |
short v2;
|
|
Packit Service |
2b1f13 |
char v1;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
case 1:
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], res->resource_name, &v1;;
|
|
Packit Service |
2b1f13 |
XtGetValues(w, args, 1);
|
|
Packit Service |
2b1f13 |
value = (int)v1;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case 2:
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], res->resource_name, &v2;;
|
|
Packit Service |
2b1f13 |
XtGetValues(w, args, 1);
|
|
Packit Service |
2b1f13 |
value = (int)v2;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case 4:
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], res->resource_name, &v4;;
|
|
Packit Service |
2b1f13 |
XtGetValues(w, args, 1);
|
|
Packit Service |
2b1f13 |
value = (int)v4;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
#ifdef LONG64
|
|
Packit Service |
2b1f13 |
case 8:
|
|
Packit Service |
2b1f13 |
XtSetArg(args[0], res->resource_name, &v8;;
|
|
Packit Service |
2b1f13 |
XtGetValues(w, args, 1);
|
|
Packit Service |
2b1f13 |
value = (long)v8;
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
default:
|
|
Packit Service |
2b1f13 |
fprintf(stderr, "_XEditresGetStringValues: bad size %d\n",
|
|
Packit Service |
2b1f13 |
res->resource_size);
|
|
Packit Service |
2b1f13 |
string = "bad size";
|
|
Packit Service |
2b1f13 |
*(char **)(warg->value) = string;
|
|
Packit Service |
2b1f13 |
XtFree((char *)res_list);
|
|
Packit Service |
2b1f13 |
return;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* If the resource is already String, no conversion needed
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
if (strcmp(XtRString, res->resource_type) == 0)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
if (value == 0)
|
|
Packit Service |
2b1f13 |
string = "(null)";
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
string = (char *)value;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
from.size = res->resource_size;
|
|
Packit Service |
2b1f13 |
from.addr = (XPointer)&value;
|
|
Packit Service |
2b1f13 |
to.addr = NULL;
|
|
Packit Service |
2b1f13 |
to.size = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (XtConvertAndStore(w,res->resource_type, &from, XtRString, &to))
|
|
Packit Service |
2b1f13 |
string = to.addr;
|
|
Packit Service |
2b1f13 |
else
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
string = buffer;
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Conversion failed, fall back to representing it as integer
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
switch (res->resource_size)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
case sizeof(char):
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xff));
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case sizeof(short):
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buffer, sizeof(buffer), "%d", (int)(value & 0xffff));
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
case sizeof(int):
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buffer, sizeof(buffer), "0x%08x", (int)value);
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
#ifdef LONG64
|
|
Packit Service |
2b1f13 |
case sizeof(long):
|
|
Packit Service |
2b1f13 |
XmuSnprintf(buffer, sizeof(buffer), "0x%016lx", value);
|
|
Packit Service |
2b1f13 |
break;
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (string == NULL)
|
|
Packit Service |
2b1f13 |
string = "";
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*(char **)(warg->value) = string;
|
|
Packit Service |
2b1f13 |
XtFree((char *)res_list);
|
|
Packit Service |
2b1f13 |
}
|